#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "mainwindow.h"
#include "file.h"
#include "save.h"
#include "exit.h"
GtkWidget *window_main; 
/*
 * callback for window_main to handle destory signal
 */
gboolean on_window_main_delete (GtkWidget       *widget,
                                        GdkEvent        *event,
                                        gpointer         user_data)
{
	struct file_ctrl *global_file=(struct file_ctrl *)user_data;
	GtkWidget *dialog;
	gint sure;

	if(global_file->data_mod) {
		gchar msg[] = "数据已经被修改，是否保存?";
		dialog = gtk_message_dialog_new(GTK_WINDOW(widget), 0,
				GTK_MESSAGE_INFO, GTK_BUTTONS_OK_CANCEL, msg);
		sure = gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
		if (sure == GTK_RESPONSE_OK) {
			save_all_file(global_file);
		}
	}
	exit_easyblog(global_file);
	gtk_main_quit();
	return FALSE;
}

/*
 * 
 */

